package com.hck.types.exception;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 应用异常
 */
@Data

@NoArgsConstructor
public class AppException extends RuntimeException {

    private static final long serialVersionUID = 5317680961212299217L;

    /** 异常码 */
    private String code;

    /** 异常信息 */
    private String message;

    public AppException(String message) {
        this.message = message;
    }

    public AppException(String code, Throwable cause) {
        this.code = code;
        super.initCause(cause);
    }

    public AppException(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public AppException(String code, String message, Throwable cause) {
        this.code = code;
        this.message = message;
        super.initCause(cause);
    }

    @Override
    public String toString() {
        return "com.hck.x.api.types.exception.XApiException{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                '}';
    }

}
